#ifndef _CWIDGETFACTORIES_H_
#define _CWIDGETFACTORIES_H_

#include <buola/algorithm/comparison.h>

#include <buola/widgets/cwidgetfactory.h>

#include <buola/widgets/cbutton.h>
#include <buola/widgets/ccombobox.h>
#include <buola/widgets/ccheckbox.h>
#include <buola/widgets/ceditbox.h>
#include <buola/widgets/clabelbox.h>
#include <buola/widgets/clistbox.h>
#include <buola/widgets/ctabbox.h>
#include <buola/widgets/cnumbox.h>
#include <buola/widgets/coptionbox.h>
#include <buola/widgets/cprogressbar.h>
#include <buola/widgets/cscrollbar.h>
#include <buola/widgets/csliderbox.h>

namespace buola { namespace gui {

class CButtonFactory : public CWidgetFactory
{
public:
    CButtonFactory()
    {
        mName=L"button";
        mDescription=L"Push button";
        mIconName="button";

        mProperties.emplace_back(new CPropertyField(L"bool",L"small",L"small"));
        mProperties.emplace_back(new CPropertyField(L"bool",L"disabled",L"disabled"));
    }

    PWindow GetOne()
    {
        return new CButton;
    }
};

class CCheckBoxFactory : public CWidgetFactory
{
public:
    CCheckBoxFactory()
    {
        mName=L"checkbox";
        mDescription=L"check box";
        mIconName="checkbutton";
        mProperties.emplace_back(new CPropertyField(L"bool",L"value",L"value"));
    }

    PWindow GetOne()
    {
        return new CCheckBox;
    }
};

class CComboBoxFactory : public CWidgetFactory
{
public:
    CComboBoxFactory()
    {
        mName=L"combo";
        mDescription=L"combo box";
        mIconName="combobox";
    }

    PWindow GetOne()
    {
        return new CComboBox;
    }
};

class CEditBoxFactory : public CWidgetFactory
{
public:
    CEditBoxFactory()
    {
        mName=L"edit";
        mDescription=L"Edit box";
        mIconName="entry";

        mProperties.emplace_back(new CPropertyField(L"bool",L"noborder",L"noborder"));
        mProperties.emplace_back(new CPropertyField(L"bool",L"disabled",L"disabled"));
        mProperties.emplace_back(new CPropertyField(L"bool",L"readonly",L"readonly"));
    }

    PWindow GetOne()
    {
        return new CEditBox;
    }
};

class CLabelBoxFactory : public CWidgetFactory
{
public:
    CLabelBoxFactory()
    {
        mName=L"label";
        mDescription=L"Label box";
        mIconName="label";
    }

    PWindow GetOne()
    {
        return new CLabelBox;
    }
};

class CListBoxFactory : public CWidgetFactory
{
public:
    CListBoxFactory()
    {
        mName=L"listbox";
        mDescription=L"list box";
        mIconName="list";

        RemoveProperty(L"caption");

        mProperties.emplace_back(new CPropertyField(L"int",L"value",L"value"));
    }

    PWindow GetOne()
    {
        return new CListBox;
    }
};

class CTabBoxFactory : public CWidgetFactory
{
public:
    CTabBoxFactory()
    {
        mName=L"tabbox";
        mDescription=L"tab box";
        mIconName="notebook";

        RemoveProperty(L"caption");
    }

    PWindow GetOne()
    {
        return new CTabBox;
    }
};

class CNumBoxFactory : public CWidgetFactory
{
public:
    CNumBoxFactory()
    {
        mName=L"numbox";
        mDescription=L"number box";
        mIconName="spinbutton";

        for(int i=0;i<mProperties.size();i++)
        {
            if(iequals(mProperties[i]->mName,L"caption"))
            {
                mProperties.erase(mProperties.begin()+i);
                break;
            }
        }

        mProperties.emplace_back(new CPropertyField(L"int",L"value",L"value"));
    }

    PWindow GetOne()
    {
        return new CNumBox;
    }
};

class COptionBoxFactory : public CWidgetFactory
{
public:
    COptionBoxFactory()
    {
        mName=L"optionbox";
        mDescription=L"option box";
        mIconName="radiobutton";
        mProperties.emplace_back(new CPropertyField(L"bool",L"value",L"value"));
        mProperties.emplace_back(new CPropertyField(L"int",L"group",L"group"));
    }

    PWindow GetOne()
    {
        return new COptionBox;
    }
};

class CProgressBarFactory : public CWidgetFactory
{
public:
    CProgressBarFactory()
    {
        mName=L"progress";
        mDescription=L"progress bar";
        mIconName="progressbar";

        for(int i=0;i<mProperties.size();i++)
        {
            if(iequals(mProperties[i]->mName,L"caption"))
            {
                mProperties.erase(mProperties.begin()+i);
                break;
            }
        }

        mProperties.emplace_back(new CPropertyField(L"int",L"value",L"value"));
    }

    PWindow GetOne()
    {
        return new CProgressBar;
    }
};

class CScrollBarFactory : public CWidgetFactory
{
public:
    CScrollBarFactory()
    {
        mName=L"scroll";
        mDescription=L"scroll bar";
        mIconName="hscrollbar";

        for(int i=0;i<mProperties.size();i++)
        {
            if(iequals(mProperties[i]->mName,L"caption"))
            {
                mProperties.erase(mProperties.begin()+i);
                break;
            }
        }

        mProperties.emplace_back(new CPropertyField(L"int",L"value",L"value"));
        mProperties.emplace_back(new CPropertyField(L"int",L"min",L"min"));
        mProperties.emplace_back(new CPropertyField(L"int",L"max",L"max"));
        mProperties.emplace_back(new CPropertyField(L"int",L"step",L"step"));
        mProperties.emplace_back(new CPropertyField(L"int",L"page",L"page"));
        mProperties.emplace_back(new CPropertyField(L"bool",L"horizontal",L"horizontal"));
    }

    PWindow GetOne()
    {
        return new CScrollBar;
    }
};

class CSliderBoxFactory : public CWidgetFactory
{
public:
    CSliderBoxFactory()
    {
        mName=L"slider";
        mDescription=L"slider box";
        mIconName="hscale";

        for(int i=0;i<mProperties.size();i++)
        {
            if(iequals(mProperties[i]->mName,L"caption"))
            {
                mProperties.erase(mProperties.begin()+i);
                break;
            }
        }

        mProperties.emplace_back(new CPropertyField(L"int",L"value",L"value"));
        mProperties.emplace_back(new CPropertyField(L"int",L"min",L"min"));
        mProperties.emplace_back(new CPropertyField(L"int",L"max",L"max"));
        mProperties.emplace_back(new CPropertyField(L"int",L"step",L"step"));
        mProperties.emplace_back(new CPropertyField(L"int",L"page",L"page"));
        mProperties.emplace_back(new CPropertyField(L"bool",L"horizontal",L"horizontal"));
    }

    PWindow GetOne()
    {
        return new CSliderBox;
    }
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
